ColdFusion Article

Employee Updater: Building a Client-Server Application with Macromedia Flash Data Connection Wizard and ColdFusion


Table of Contents

  1. Introduction
  2. The Back-End ColdFusion Web Service
  3. Preparing Flash
  4. Building the Flash Departments Grid
  5. Creating the Login Screen
  6. Processing Logins
  7. Logging Out
  8. Allowing Insert and Delete
  9. Managing Changes
  10. Processing Updates

Logging Out

Next, you'll create a logout button. To make it easy to switch between the login and logout buttons, and the buttons you'll add for insert, delete, and save, you''ll put the logout button on a separate form:

  1. Add another form to the application and name it navLogout.
  2. Select navLogout in the form tree and go to the Property inspector. Set the visible parameter to false. You do not want the Insert, Delete, Save, and Logout buttons to display on startup (before a user logs in).
  3. Select the navLogout form and add a Button component to it. In the Property inspector, name the instance buttonLogout. Set W=75, H=22, X=460, Y=370. Click the label field and set it to Logout.
  4. Click the new Logout button in the navLogout form and open the Actions panel.
  5. Type the following code in the Actions panel:

    // Process logout
    on (click) {
       // Hide logout buttons
       _root.application.navLogout.visible=false;
       // Show login button
       _root.application.navLogin.visible=true;
       // No more editable
       _root.application.data.empDataGrid.editable=false;
    }
    
  6. The above code ensures that upon log-out, the SWF hides the Logout button and displays Login button again. The opposite needs to occur upon log-on, so select the login form and the authService component, and insert the following two lines before the comment that reads // Close login popup:

    // Hide login buttons
    _root.application.navLogin.visible=false;
    // Show logout button
    _root.application.navLogout.visible=true;
    
  7. Save the changes and run the application. You should be able to log in and log out as needed. When you log in, the code lets you edit the employees in the grid and displays the Logout button; when you log out, the code prevents you from being able to edit and displays the Login button again.